#include "Parser.h"
#include "ElementDOM.h"

#include "Martiale.h"

#include "lib.h"

#include "LireMartiales.h"

#include <boost/foreach.hpp>

using namespace std;
using namespace boost;

int main( int argc, char * argv[] )
{
  cout << "########################################" << endl
       << "Teste la lecture auto de ListeArmes.xml" << endl
       << "########################################" << endl << endl;

  //const LireMartiales * liste = initLectureArmesXML();
  LireMartiales * liste  = UniqueLireMartiales::instance();

  if ( liste == 0 )
    {
      cout << "Pointeur nul !" << endl;
      return 1;
    }

  liste -> init();

  vector< Martiale > Armes;
  
  Armes.assign( liste -> listeArmes() -> begin(),
		liste -> listeArmes() -> end() );

  cout << "En tout, il existe " << Armes.size() << " compétences martiales"
       << endl;

  BOOST_FOREACH( Martiale arme, Armes )
    {
      cout << "\t";
      arme . afficheTout( cout );
      cout << endl;
    }

  cout << endl;

  vector< GLarge > gLarges;

  gLarges.assign( liste -> groupesLarges() -> begin(),
		  liste -> groupesLarges() -> end() );

  vector< string > gRestreints;
  string r;

  BOOST_FOREACH( GLarge g, gLarges )
    {
      cout << g.Nom << endl;
      if ( g.Restreints > 0 )
	{
	  gRestreints.assign( g.NomsRestreints.begin(),
			      g.NomsRestreints.end() );
	  BOOST_FOREACH( r, gRestreints )
	    cout << "- " << r << endl;
	}
    }

  UniqueLireMartiales::tueInstance();

  return 0;
}
